<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="huoyun" uri="/huoyun"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>搜索货源</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/theme/css/dialog.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/car/css/search-goods.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/theme/js/dialog.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/theme/css/main.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/theme/css/style_userCenter.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/theme/js/jquery-1.6.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/car/js/jarea-by-chengxin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/car/js/publish-car-tzh.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/theme/js/calendar/WdatePicker.js"></script>
<script type="text/javascript">
	function add_event(e) {
		e.onmouseover = function() {
			e.className += ' hover';
		};
		e.onmouseout = function() {
			e.className = e.className.replace(' hover', '');
			e.className = e.className.replace(' active', '');
		};
		e.onmousedown = function() {
			e.className = e.className.replace(' hover', ' active');
		};
		e.onmouseup = function() {
			e.className = e.className.replace(' active', ' hover');
		};
	}

	/*
		弹出窗：应标后出价
	 */
	function openDialog(goodsId, bid) {
		var urlStr = "/huoyun/cargo/getCar2Bid.action?goodsId=" + goodsId
				+ "&bid=" + bid + "&r=" + Math.random();
		simpleBox.open({
			type : 'url',
			value : urlStr
		});
	}

	/*
		打开已有多少人参与应标窗口
	 */
	function openDialog2(goodsId, type) {
		if (type == 'bid') {
			var urlStr = "/huoyun/cargo/getAllBiddingCars.action?goodsId="
					+ goodsId + "&r=" + Math.random();
			new Dialog({
				type : 'url',
				value : urlStr
			}, {
				fixed : false
			}, {
				title : '详细应标信息'
			}).show();
		} else if (type == 'detail') {
			var urlStr = "/huoyun/cargo/getCargoDetailForCar.action?goodsId="
					+ goodsId;
			new Dialog({
				type : 'url',
				value : urlStr
			}, {
				fixed : false
			}, {
				title : '详细货物信息'
			}).show();
		}
	}

	function changeVisible() {
		if ($("#goods_search_div").is(":hidden")) {
			$("#goods_search_a").html("隐藏搜索器<<");
			$("#goods_search_div").slideToggle("fast");
		} else {
			$("#goods_search_a").html("修改搜索器>>");
			$("#goods_search_div").slideToggle("fast");
		}
	}

	function showCompleteCargoInfo(index) {
		$('#' + index).slideToggle("fast");
	}

	$(document).ready(function() {
		$("#carDetailID").change(function() {
			var carId = $("#carDetailID").val();
			$.ajax({
				type : "post", // 请求方式为POST，避免乱码问题
				url : "cargo/getDriverSearcherByCar.action", // 发送请求地址
				data : { // 发送给数据库的数据
					carId : carId,
					ajax : "true"
				},
				dataType : "json", // 接收的数据格式为JSON，如果不指定则自动检测
				success : function(jsondata, textStatus) {
					alert(jsondata["fromProvince"]);

					$("#fromProvince").val(jsondata["fromProvince"]);
					$("#fromCity").val(jsondata["fromCity"]);
					$("#fromTown").val(jsondata["fromTown"]);
					$("#toProvince").val(jsondata["toProvince"]);
					$("#toCity").val(jsondata["toCity"]);
					$("#toTown").val(jsondata["toTown"]);
					$("#fromDate").val(jsondata["fromDate"]);
					$("#toDate").val(jsondata["toDate"]);
				}
			});
		});
	});

	window.onload = function() {
		var button = document.getElementById('submit_button');
		add_event(button);
	}
</script>

<style type="text/css">
#bid_button {
	width: 100px;
	height: 80px;
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_normal.png");
	background-size: 100% 100%;
	border: none;
	cursor: pointer;
	font-family: 宋体;
	font-size: 18px;
	font-style: normal;
	color: #fff;
	font-weight: bold;
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_normal_ie.png")
		\9;
}

#bid_button:hover,#bid_button.hover {
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_hover.png");
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_hover_ie.png")
		\9;
}

#bid_button:active,#bid_button.active {
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_down.png");
	background-image:
		url("${pageContext.request.contextPath}/theme/images/button_down_ie.png")
		\9;
}

.red {
	color: red;
}
</style>

</head>

<body>
	<div>
		<jsp:include page="../../userAdmin/nav.jsp">
			<jsp:param value="nav_main" name="nav" />
		</jsp:include>
	</div>
	<div class="realCer">

		<!--主体部分-->
		<div class="realMain clearfix mt10">
			<!--左侧菜单-->
			<div class="realLeft" id="meunLeft">
				<jsp:include page="../../userAdmin/leftMenu.jsp">
					<jsp:param value="con_nav_main" name="con_nav" />
					<jsp:param value="preSearchGoods" name="selectMenu" />
				</jsp:include>
			</div>
			<!--中间-->
			<div class="realRight ml10">
				<!--中间-->
				<div class="realR_left" style="width: 835px;">
					<div class="box" style="width:100%;">
						<div class="tit">
							<strong>我的搜索器</strong> <a id="goods_search_a" onclick="changeVisible();"> 修改搜索器>> </a>
						</div>
						<div class="con" id="goods_search_div"
							style="display:none; -moz-box-shadow: inset 0px 0px 8px #000000; -webkit-box-shadow: inset 0px 0px 8px #000000; box-shadow: inset 0px 0px 8px #000000;">
							<form action="/huoyun/cargo/cargoSelectionBasic.action"
								name="set_searcher_form" method="post">
								<table>
									<tr>
										<td width="450px;">
											<table width="450px">
												<tr>
													<td>起始地：</td>
													<td id="fromArea"><huoyun:regionSelect
															provinceName="driverSearcher.fromProvince"
															cityName="driverSearcher.fromCity"
															townName="driverSearcher.fromTown"
															provinceValue="${driverSearcher.fromProvince }"
															cityValue="${driverSearcher.fromCity }"
															townValue="${driverSearcher.fromTown }" /></td>
												</tr>
												<tr>
													<td>目的地：</td>
													<td id="toArea"><huoyun:regionSelect
															provinceName="driverSearcher.toProvince"
															cityName="driverSearcher.toCity"
															townName="driverSearcher.toTown"
															provinceValue="${driverSearcher.toProvince }"
															cityValue="${driverSearcher.toCity }"
															townValue="${driverSearcher.toTown }" /></td>
												</tr>
											</table></td>
										<td width="100px" align="right"><input
											style="width:80px; height:80px; top:0px;" type="submit"
											value="搜索"></td>
									</tr>
								</table>
								<table>
									<tr>
										<td>货物类型：</td>
										<td><huoyun:customSelect mode="cargosType"
												name="driverSearcher.cargoType"
												value="${driverSearcher.cargoType }" />
										</td>
									</tr>
									<tr>
										<td>包装类型：</td>
										<td><huoyun:customSelect mode="cargoPackageType"
												name="driverSearcher.packageType"
												value="${driverSearcher.packageType }" />
										</td>
									</tr>
									<tr>
										<td>货物数量：</td>
										<td><s:textfield name="driverSearcher.carryingNumLower"
												theme="simple"></s:textfield>吨 以上 <br> <s:textfield
												name="driverSearcher.carryingNumUpper" theme="simple"></s:textfield>吨
											以下</td>
									</tr>
									<tr>
										<td>车辆类型：</td>
										<td><huoyun:customSelect mode="carRequiredType"
												name="driverSearcher.carType"
												value="${driverSearcher.carType }" />
										</td>
									</tr>
									<tr>
										<td>装货时间：</td>
										<td><input id="loadTimeStart"
											name="driverSearcher.loadStartTime"
											value="<huoyun:dateFormat date="${driverSearcher.loadStartTime }" dateFormat="yyyy-MM-dd HH:mm" />"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之后 <br> <input id="loadTimeEnd"
											name="driverSearcher.loadEndTime"
											value="<huoyun:dateFormat date="${driverSearcher.loadEndTime }" dateFormat="yyyy-MM-dd HH:mm" />"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之前</td>
									</tr>
									<tr>
										<td>发货时间：</td>
										<td><input id="leaveStartTime"
											name="driverSearcher.leaveStartTime"
											value="<huoyun:dateFormat date="${driverSearcher.leaveStartTime }" dateFormat="yyyy-MM-dd HH:mm"/>"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之后 <br> <input id="leaveEndTime"
											name="driverSearcher.leaveEndTime"
											value="<huoyun:dateFormat date="${driverSearcher.leaveEndTime }" dateFormat="yyyy-MM-dd HH:mm"/>"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之前</td>
									</tr>
									<tr>
										<td>卸货时间：</td>
										<td><input id="unloadStartTime"
											name="driverSearcher.unloadStartTime"
											value="<huoyun:dateFormat date="${driverSearcher.unloadStartTime }" dateFormat="yyyy-MM-dd HH:mm" />"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之后 <br> <input id="unloadEndTime"
											name="driverSearcher.unloadEndTime"
											value="<huoyun:dateFormat date="${driverSearcher.unloadStartTime }" dateFormat="yyyy-MM-dd HH:mm" />"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之前</td>
									</tr>
									<tr>
										<td>应标截止时间：</td>
										<td><input id="bidEndStartTime"
											name="driverSearcher.bidEndStartTime"
											value="<huoyun:dateFormat date="${driverSearcher.bidEndStartTime }" dateFormat="yyyy-MM-dd HH:mm" />"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之后 <br> <input id="bidEndEndTime"
											name="driverSearcher.bidEndEndTime"
											value="<huoyun:dateFormat date="${driverSearcher.bidEndEndTime }" dateFormat="yyyy-MM-dd HH:mm" />"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之前</td>
									</tr>
									<tr>
										<td>货物信息发布时间：</td>
										<td><input id="cargoInfoCreateStartTime"
											name="driverSearcher.cargoInfoCreateStartTime"
											value="<huoyun:dateFormat date="${driverSearcher.cargoInfoCreateStartTime }" dateFormat="yyyy-MM-dd HH:mm" />"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之后 <br> <input
											id="cargoInfoCreateEndTime"
											name="driverSearcher.cargoInfoCreateEndTime"
											value="<huoyun:dateFormat date="${driverSearcher.cargoInfoCreateEndTime }" dateFormat="yyyy-MM-dd HH:mm" />"
											class="Wdate"
											onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});"
											style="width:140px" />之前</td>
									</tr>
								</table>
							</form>
						</div>


						<s:if test="cargoItemPage">
							<%
								request.setAttribute("currentTime", new java.util.Date());
							%>
							<div class="item-list-div" id="item-list-div">
								<div class="route-div" id="route-div"></div>
								<div class="goods-list-div" id="goods-list-div">
									<div class="goods-list-title" id="goods-list-title">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<th width="12%" align="center" valign="middle" style="border-left:none;">货主</th>
												<th width="15%" align="center" valign="middle">货物名称</th>
												<th width="15%" align="center" valign="middle">总重量<br />总体积</th>
												<th width="23%" align="center" valign="middle">装货时间区间</th>
												<th width="16%" align="center" valign="middle">货主报价(元)<br />车型要求</th>
												<th width="19%" align="center" valign="middle">操作</th>
											</tr>
										</table>
									</div>
									<s:iterator value="cargoItemPage.objectList" id="cargoItem" status="st">
										<div class="goods-content" id="goods-content">
											<div class="goods-item-div" id="goods-item-div">
												<div class="user-img" id="user-img">
													<img src="${pageContext.request.contextPath}/${cargoItem.user.userImg }" width="95%" height="100%" />
												</div>
												<div class="goods-title" id="goods-title">
													<div class="goods-title-content" id="goods-title-content"><s:property value="#cargoItem.cargoInfo.title" /></div>
													<div class="goods-comment" id="goods-comment"><a href="">查看详情</a></div>
													<div class="goods-user" id="goods-user"><a href=""><s:property value="#cargoItem.user.username" /></a></div>
												</div>
												<div class="goods-amount-volumn" id="goods-amount-volumn">
													<div class="goods-amount" id="goods-amount">
														<s:property value="#cargoItem.cargoInfo.amount" />&nbsp;吨<br /> xxxx&nbsp;m³
													</div>
												</div>
												<div class="goods-bid-car" id="goods-bid-car">
													<div class="goods-bid-endtime" id="goods-bid-endtime">
														从：<huoyun:dateFormat date="${cargoItem.cargoInfo.loadStartTime }" dateFormat="yyyy-MM-dd HH:mm" /><br />
														到：<huoyun:dateFormat date="${cargoItem.cargoInfo.loadEndTime }" dateFormat="yyyy-MM-dd HH:mm" />
													</div>
												</div>
												<div class="goods-freight" id="goods-freight">
													<div class="goods-freight-content" id="goods-freight-content">
														&yen;<strong style="color:red; font-size:14px;"><s:property value="#cargoItem.cargoInfo.freight" /></strong>&nbsp;元<br />
														<span style="font-size:13px;"><huoyun:customSelect mode="carRequiredType" value="${cargoItem.cargoInfo.carRequired }" type="view" /></span>
													</div>
												</div>
												<div class="goods-option" id="goods-option">
													<s:if test="#cargoItem.cargoInfo.bidEndTime > #request.currentTime">
													  	<div id="goods-bid-button" class="goods-bid-button button button-lorange">
													  		<input type="button" value="出价" class="button-text" onclick="openDialog(<s:property value="#cargoItem.cargoInfo.id"/>,<s:property value="#cargoItem.cargoInfo.freight"/>)" />
													  	</div>
												  	</s:if>
												  	<s:else>
													  	<div id="goods-bid-button" class="goods-bid-button button button-ldisable">
															<input type="submit" value="出价" class="button-text">
														</div>
													</s:else>
													<div class="goods-bidding-user" id="goods-bidding-user"><a href="" onclick="openDialog2(<s:property value="#cargoItem.cargoInfo.id"/>,'bid'); return false;">已有<s:property value="#cargoItem.bidInfoItemList.size()"/>人参与应标</a></div>
													<div class="goods-createtime" id="goods-createtime">
														<s:property value="#cargoItem.cargoInfo.addTimeForPeriod" />&nbsp;发布
													</div>
												</div>
											</div>
										</div>
									</s:iterator>
									<s:if test="cargoItemPage.totalPage > 1">
									    <s:url var="queryCargoUrl" action="preSearchGoods.action" namespace="/channel"></s:url>
										<huoyun:page pageNo="${cargoItemPage.pageNo}" url="${queryCargoUrl}" totalPage="${cargoItemPage.totalPage}" totalRecord="${cargoItemPage.totalRecord}"></huoyun:page>
									</s:if>
								</div>
							</div>
						</s:if>
					</div>
				</div>
				<!-- 中间 -->
			</div>
			<!--中由-->
		</div>
	</div>
	<div>
		<jsp:include page="/footer.jsp"></jsp:include>
	</div>
</body>
</html>
